#include <QVariant>
#include <QDebug>
#include <QMetaObject>
#include "ConfigData.h"


#define CONFIG_ITEM(TYPE,ID) \
    ID = new TYPE; \
    ID->setObjectName(#ID); \
    ID->translatedName = tr(#ID);

#define CONFIG_ENUM(TYPE,ID) \
    ID = new ItemEnum; \
    ID->setObjectName(#ID); \
    ID->translatedName = tr(#ID); \
    ID->setMetaEnum(QMetaEnum::fromType<TYPE>());

#define CONFIG_FLAG(TYPE,ID) \
    ID = new ItemFlag; \
    ID->setObjectName(#ID); \
    ID->translatedName = tr(#ID); \
    ID->setMetaEnum(QMetaEnum::fromType<TYPE>());

#define CONFIG_DATA_MODEL(TYPE,ID) \
    ID = new TYPE; \
    ID->setObjectName(#ID); \
    ID->translatedName = tr(#ID);

static const char *cuw = nullptr; // clear Unused Warrings

Data1::Data1(QObject *parent) : ConfigDataModel(parent)
{
    // copy CONFIG from Datas.h
    CONFIG_ITEM(ItemString, userName)
    CONFIG_ITEM(ItemInt, height)
    CONFIG_ITEM(ItemDouble, zoom)
    CONFIG_ITEM(ItemBool, isLogin)
    CONFIG_ITEM(ItemShortcut, shortCut)
    CONFIG_ENUM(OS, system)
    CONFIG_FLAG(Option, options)

    CONFIG_DATA_MODEL(Data2, data2)
    //
    ensureItemRegisterd();
    //

    system->setWidgetStyle(ItemEnum::ComboBox);

    // translate
    cuw = QT_TR_NOOP("userName");
    cuw = QT_TR_NOOP("height");
    cuw = QT_TR_NOOP("zoom");
    cuw = QT_TR_NOOP("isLogin");
    cuw = QT_TR_NOOP("system");
    cuw = QT_TR_NOOP("options");
    cuw = QT_TRANSLATE_NOOP("ItemFlag", "T1");
    cuw = QT_TRANSLATE_NOOP("ItemFlag", "T2");
    cuw = QT_TRANSLATE_NOOP("ItemFlag", "T3");

}

Data2::Data2(QObject *parent) : ConfigDataModel(parent)
{
    CONFIG_ITEM(ItemStringList, list)
    CONFIG_ITEM(ItemColor, textColor)
    //
    ensureItemRegisterd();
    //
    cuw = QT_TR_NOOP("list");
    cuw = QT_TR_NOOP("textColor");

}

inline unsigned int GET(void *ptr)
{
    return *(unsigned int *)ptr;
}


#undef CONFIG_ITEM
#undef CONFIG_ENUM
#undef CONFIG_FLAG


